package com.bosssoft.hr.train.spring.Aop;

import com.bosssoft.hr.train.spring.Aop.service.UserServiceImpl2;
import com.bosssoft.hr.train.spring.service.UserServiceImpl;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @Author: wang
 * @Time: 2022/3/7
 */
@Aspect//表示这是一个切面类
@Component
public class TransactionAspect {

    @Pointcut("execution(* com.bosssoft.hr.train.spring.Aop.service.UserService2.deleteById(..))")
    public void servicePoint(){

    }

    @Around("servicePoint()")
    public int pointcut(ProceedingJoinPoint p){
        Object obj=null;
        try {
            Object[] o=p.getArgs();
            if (o.length>0)
            return 1;
        } catch (Throwable e) {
            return 0;
        }
        return 0;
    }
}
